package com.ygqh.baby.model;

import com.ygqh.baby.ao.OrderDetailStatus;
import com.ygqh.baby.ao.ProductStatus;
import com.ygqh.baby.ao.PromotionType;
import com.ygqh.baby.ao.RefundStatus;
import org.apache.commons.lang.StringUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class YgOrderDetailModel {

	private Long orderDetailId;

	private Long skuId;

	private String skuCode;

	private String productName;

	private String shortName;

	private Long productId;

	private BigDecimal salePrice;

	private BigDecimal sourceSalePrice;

	private String size;

	private String imageUrl;

	private Long quantity;

	private String unitName;

	private PromotionType promotionType;

	private Date preSaleDate;

	private ProductStatus saleStatus;

	private Long stockNum;

	private String remark;

	/**
	 * 是否发货
	 */
	private String sendMark;

	private OrderDetailStatus detailStatus;

	private RefundStatus refundStatus;

	/**
	 * 是否存在退换货
	 */
	private Boolean isReturn;

	// ===============
	private String categoryNames;

	public Long getOrderDetailId() {
		return orderDetailId;
	}

	public void setOrderDetailId(Long orderDetailId) {
		this.orderDetailId = orderDetailId;
	}

	public String getRemark() {
		return remark;
	}

	public RefundStatus getRefundStatus() {
		return refundStatus;
	}

	public void setRefundStatus(RefundStatus refundStatus) {
		this.refundStatus = refundStatus;
	}

	public OrderDetailStatus getDetailStatus() {
		return detailStatus;
	}

	public void setDetailStatus(OrderDetailStatus detailStatus) {
		this.detailStatus = detailStatus;
	}

	public String getDetailStatusStr() {
		if (detailStatus != null && refundStatus.equals(RefundStatus.NoRefund)) {
			return detailStatus.getTitle();
		}
		return refundStatus.getTitle();
	}

	public String getSendMark() {
		return sendMark;
	}

	public void setSendMark(String sendMark) {
		this.sendMark = sendMark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Long getStockNum() {
		return stockNum;
	}

	public void setStockNum(Long stockNum) {
		this.stockNum = stockNum;
	}

	public ProductStatus getSaleStatus() {
		if (ProductStatus.Invisible.equals(saleStatus)) {
			return ProductStatus.OnSale;
		}

		return saleStatus;
	}

	public void setSaleStatus(ProductStatus saleStatus) {
		this.saleStatus = saleStatus;
	}

	public Boolean getIsReturn() {
		return isReturn;
	}

	public void setIsReturn(Boolean isReturn) {
		this.isReturn = isReturn;
	}

	public Date getPreSaleDate() {
		return preSaleDate;
	}

	public void setPreSaleDate(Date preSaleDate) {
		this.preSaleDate = preSaleDate;
	}

	public Long getProductId() {
		return productId;
	}

	public void setProductId(Long productId) {
		this.productId = productId;
	}

	public BigDecimal getSourceSalePrice() {
		return sourceSalePrice;
	}

	public void setSourceSalePrice(BigDecimal sourceSalePrice) {
		this.sourceSalePrice = sourceSalePrice;
	}

	public String getShortName() {
		return shortName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

	public Long getSkuId() {
		return skuId;
	}

	public void setSkuId(Long skuId) {
		this.skuId = skuId;
	}

	public String getSkuCode() {
		return skuCode;
	}

	public void setSkuCode(String skuCode) {
		this.skuCode = skuCode == null ? null : skuCode.trim();
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName == null ? null : productName.trim();
	}

	public BigDecimal getSalePrice() {
		return salePrice;
	}

	public void setSalePrice(BigDecimal salePrice) {
		this.salePrice = salePrice;
	}

	public String getSize() {
		return size;
	}

	public void setSize(String size) {
		this.size = size == null ? null : size.trim();
	}

	public String getImageUrl() {
		return imageUrl;
	}

	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl == null ? null : imageUrl.trim();
	}

	public Long getQuantity() {
		return quantity;
	}

	public void setQuantity(Long quantity) {
		this.quantity = quantity;
	}

	public String getUnitName() {
		return unitName;
	}

	public void setUnitName(String unitName) {
		this.unitName = unitName == null ? null : unitName.trim();
	}

	public PromotionType getPromotionType() {
		return promotionType;
	}

	public void setPromotionType(PromotionType promotionType) {
		this.promotionType = promotionType == null ? null : promotionType;
	}

	public String getCategoryNames() {
		return categoryNames;
	}

	public void setCategoryNames(String categoryNames) {
		this.categoryNames = categoryNames;
	}

	public List<String> getCategoryNameList() {
		List<String> categoryNameList = new ArrayList<>();
		if (StringUtils.isNotBlank(categoryNames)) {
			for (String categoryName : categoryNames.split(",")) {
				if (StringUtils.isNotBlank(categoryName)) {
					categoryNameList.add(categoryName);
				}
			}
		}
		if (categoryNameList.size() == 0) {
			categoryNameList.add("其它");
		}
		return categoryNameList;
	}
}